# _*_ coding : utf-8 _*_
# @Time : 2022/8/9 20:14
# @Author : Moonquake
# @File : 17.代理
# @Project : python
import urllib.request
url='http://www.baidu.com/s?wd=ip'
headers={
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36 Edg/104.0.1293.47'
}
request = urllib.request.Request(url=url,headers=headers)

proxies = {
    'http':'171.92.21.175:9000'
}

handler = urllib.request.ProxyHandler(proxies=proxies)

opener =urllib.request.build_opener(handler)

response = opener.open(request)

content = response.read().decode('utf-8')

with open('daili.html','w',encoding='utf-8') as fp:
    fp.write(content)
